﻿@using Radzen
@using System.Linq.Dynamic.Core
@using Microsoft.AspNetCore.Components.Forms
@using Microsoft.JSInterop
@typeparam TValue

<li class="@(ListBox.isSelected(Item) ? "rz-multiselect-item  rz-state-highlight" : "rz-multiselect-item ")" aria-label="@PropertyAccess.GetItemOrValueFromProperty(Item, ListBox.TextProperty)" style="display: block;" @onclick="@(async () => { if (!ListBox.Disabled) { await ListBox.SelectItemInternal(Item); } })">
    @if (ListBox.Multiple)
    {
        <div class="rz-chkbox ">
            <div class="@(ListBox.isSelected(Item) ? "rz-chkbox-box    rz-state-active" : "rz-chkbox-box   ")">
                <span class="@(ListBox.isSelected(Item) ? "rz-chkbox-icon  rzi rzi-check" : "rz-chkbox-icon ")"></span>
            </div>
        </div>
    }
    <span>
        @if (ListBox.Template != null)
        {
            @ListBox.Template(Item)
        }
        else
        {
            @PropertyAccess.GetItemOrValueFromProperty(Item, ListBox.TextProperty)
        }
    </span>
</li>

@code {
    [Parameter]
    public RadzenListBox<TValue> ListBox { get; set; }

    [Parameter]
    public object Item { get; set; }
}